package com.ruoyi.web.controller.school;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.school.domain.PacCertType;
import com.ruoyi.school.service.PacCertTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api("证书类型")
@RestController
@RequestMapping("/school/certType")
public class PacCertTypeController extends BaseController {
    @Resource
    private PacCertTypeService pacCertTypeService;

    @ApiOperation("证书类型列表")
    @GetMapping("/list")
    public TableDataInfo list(PacCertType rePacCertType) {
        startPage();
        List<PacCertType> list = pacCertTypeService.getList(rePacCertType);
        return getDataTable(list);
    }

    @ApiOperation("证书类型详情")
    @GetMapping("/details")
    public AjaxResult details(PacCertType rePacCertType) {
        PacCertType details = pacCertTypeService.getDetails(rePacCertType);
        return success(details);
    }

    @ApiOperation("证书类型新增")
    @Log(title = "证书类型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PacCertType rePacCertType) {
        boolean add = pacCertTypeService.add(rePacCertType);
        return success(add);
    }

    @ApiOperation("证书类型更新")
    @Log(title = "证书类型", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@RequestBody PacCertType rePacCertType) {
        boolean update = pacCertTypeService.edit(rePacCertType);
        return success(update);
    }

    @ApiOperation("证书类型删除")
    @Log(title = "证书类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(PacCertType rePacCertType) {
        boolean delete = pacCertTypeService.delete(rePacCertType);
        return success(delete);
    }

    @ApiOperation("所有证书类型")
    @GetMapping("/all")
    public AjaxResult all(PacCertType rePacCertType) {
        List<PacCertType> list = pacCertTypeService.getAllList(rePacCertType);
        return success(list);
    }


}
